/**
 * Created by fangzehua on 2017/7/4.
 */
$(function () {


    $('#productTableEvents').bootstrapTable({
        url: "product_list",
        search: false,
        pagination: true,
        showRefresh: false,
        showToggle: false,
        showColumns: false,
        pageSize:15,
        height:600,
        iconSize: 'outline',
        toolbar: '#productTableEventsToolbar',
        columns:[
            {
                field:'pid',
                title:'名称'
            },
            {
                field:'pname',
                title:'名称'
            },
            {
                field:'menuName',
                title:'收藏分类'
            },
            {
                field:'menuRemark',
                title:'分类'
            },
            {
                field:'price',
                title:'价格'
            },
            {
                field:'commission',
                title:'佣金'
            },
            {
                field:'couponname',
                title:'是否有券'
            },
            {
                field:'flag',
                title:'平台',
                formatter: function(value, row, index) {
                    if(row.flag == 0) {
                        return " ";
                    } else {
                        return "推荐";
                    }
                }
            },
            {
                field:'isnew',
                title:'是否上新',
                formatter: function(value, row, index) {
                    if(row.isnew == 0) {
                        return " ";
                    } else {
                        return "上新";
                    }
                }
            },

            {
                field:'addtime',
                title:'更新时间'
            },      {
                field:'action',
                title:'操作',
                width:200,
                formatter: function(value, row, index) {
                    return [
                        '<shiro:hasPermission name="admin:ordervip:update">'+
                        '<a class="edit ml10" href="javascript:void(0)" title="修改">'+
                        '<i class="glyphicon glyphicon-edit"></i></a></shiro:hasPermission>&nbsp;&nbsp;&nbsp;&nbsp;',
                        '<shiro:hasPermission name="admin:ordervip:plus">'+
                        '<a class="plus ml12" href="javascript:void(0)" title="参数">'+
                        '<i class="glyphicon glyphicon-plus"></i></a></shiro:hasPermission>&nbsp;&nbsp;&nbsp;&nbsp;',
                        '<shiro:hasPermission name="admin:ordervip:clear">'+
                        '<a class="delete ml12" href="javascript:void(0)" title="删除">'+
                        '<i class="glyphicon glyphicon-remove-circle"></i></a></shiro:hasPermission>'
                    ].join('');
                },    //紫色为添加图标（icon），插件：font-awesome，效果图见底部。
                events: {
                    'click .delete': function(e, value, row, index) {
                        alert("暂无权限删除商品!");
                    },
                    'click .edit': function(e, value, row, index) {
                        window.location.href="doEditor/"+row.id;
                    },
                    'click .plus': function(e, value, row, index) {
                        window.location.href="product/"+row.id;
                    }
                }
            },
    ]
    });


});